<?php
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.DS.'helpers');
include 'includes/viewitem.php';

?>

<?php echo $cf_type;?>	



<div id="anchorItem<?php echo JRequest::getInt('id'); ?>" class="viewItem">

<?php if ($params->get('show_title')) : ?>
<h1 class="itemTitle">
	<?php echo $this->escape($this->item->title); ?>		
</h1>	
 <?php endif;?>
 
<?php if ($params->get('show_create_date') || $params->get('show_author')|| $params->get('show_category')) : ?>
<div class="itemInfo">
	<?php if ($params->get('show_create_date')) : ?>
    <span class="itemDate"><?php echo JHtml::_('date',$this->item->created, JText::_('DATE_FORMAT_LC2')); ?></span>
    <?php endif;?>
    <?php if ($params->get('show_category')) : ?>
    <span class="itemCat"><?php 	$title = $this->escape($this->item->category_title);
	$url = '<a href="'.JRoute::_(ContentHelperRoute::getCategoryRoute($this->item->catslug)).'">'.$title.'</a>';?>
	<?php if ($params->get('link_category') AND $this->item->catslug) : ?>
		<?php echo JText::sprintf($url); ?>
	<?php else : ?>
		<?php echo JText::sprintf($title); ?>
	<?php endif; ?></span>
    <?php endif;?> 
    <?php if ($params->get('show_author') && !empty($this->item->author )) : ?>
    <span class="itemAuthor"><?php $author = $this->item->created_by_alias ? $this->item->created_by_alias : $this->item->author; ?>
	<?php if (!empty($this->item->contactid) && $params->get('link_author') == true): ?>
	<?php
		$needle = 'index.php?option=com_contact&view=contact&id=' . $this->item->contactid;
		$item = JSite::getMenu()->getItems('link', $needle, true);
		$cntlink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
	?>
		<?php echo JText::sprintf(JHtml::_('link', JRoute::_($cntlink), $author)); ?>
	<?php else: ?>
		<?php echo JText::sprintf($author); ?>
	<?php endif; ?></span>
    <?php endif;?>   
</div>
<?php endif;?>	
   
<?php if ($params->get('show_print_icon') || $params->get('show_email_icon')) : ?>
<div class="itemToolBar">
    	<?php if ($params->get('show_print_icon')) :?>
        <span class="toolPrint"><?php echo JHtml::_('icon.print_popup',  $this->item, $params); ?></span>
        <?php endif;?>
        <?php if ($params->get('show_email_icon')) :?>
        <span class="toolEmail"><?php echo JHtml::_('icon.email',  $this->item, $params); ?></span>	
        <?php endif;?>    
</div>
<?php endif;?>

<?php if($customdata->get('cf_image_display') && $image && JRequest::getInt('start')==0) :?>
<div class="itemImage">
	<img src="<?php echo $imageurl;?>" alt="<?php echo $alt;?>" />
	
</div>
<?php endif;?>



<?php if($customdata->get('cf_text_display',1)):?>
<div class="itemBody">
	<?php if (isset ($this->item->toc)) : ?>
		<div class="itemToc"><?php echo $this->item->toc; ?></div>
	<?php endif; ?>
    
    <?php if($customdata->get('cf_sapo_display') && $sapo && JRequest::getInt('start')==0 ) :?>
	<div class="itemSapo">
    	<p><?php echo $sapo;?></p>
    </div>
    <?php endif;?>      
    <div class="itemText">
    	<?php echo $this->item->event->beforeDisplayContent; ?>
			<?php echo $this->item->text; ?>
        <?php echo $this->item->event->afterDisplayContent; ?> 
	</div>    
</div>
<?php endif;?>
<?php if(($cf_gallery_display)==1):?>
<div id="itemGallery">
<h3 class="itemTitle">Gallery</h3>
<ul>
<?php	
	$folder = 'upload/gallery/'.$cf_gallery.'';
	$handle=opendir($folder);
	$i=1;
	while (false!==($file = readdir($handle)))

    {
	$path_parts = pathinfo($file);
	
    if ($file != "." && $file != ".." && $path_parts['extension']=='jpg' || $path_parts['extension']=='png')

    { ;?>
    <li class="itemGallery"><a href="<?php echo $this->baseurl ?>/<?php echo $folder;?>/<?php echo $file;?>" title="<?php echo $this->item->title;?> <?php echo $i ;?>"><img src="includes/slir/?w=<?php echo $cf_gallery_width;?>&amp;h=<?php echo $cf_gallery_height;?>&amp;q=<?php echo $cf_gallery_quality;?>&amp;c=<?php echo $cf_gallery_ratio;?>&amp;i=<?php echo $this->baseurl ?>/<?php echo $folder;?>/<?php echo $file;?>" alt="<?php echo $this->item->title;?> <?php echo $i ;?>" /></a></li>    
    <?php $i++;?>
	<?php }
    }
	closedir($handle); 
	?>
    <li class="clr"></li>
</ul>
</div>
<?php endif;?>
<?php if(($cf_video_display)==1):?>
<div id="itemVideo">
<h3 class="itemTitle">Video</h3>
<?php echo $cf_video;?>
</div>
<?php endif;?>
<?php if ($params->get('show_hits') || $params->get('show_modify_date')) : ?>
<div class="itemSubInfo">	
    <?php if ($params->get('show_modify_date')) : ?>
	<span class="itemEdit fR"><?php echo JText::sprintf('COM_CONTENT_LAST_UPDATED', JHtml::_('date',$this->item->modified, JText::_('DATE_FORMAT_LC2'))); ?></span>    
	<?php endif; ?>
    <?php if ($params->get('show_hits')) : ?>
	<span class="itemHits"><?php echo JText::sprintf('COM_CONTENT_ARTICLE_HITS', $this->item->hits); ?></span>
    <?php endif;?>	
</div>
<?php endif; ?>	

<?php if($customdata->get('cf_tags_display') !=0) :?>
<div class="itemTags">	
	<?php for($i=0; $i<sizeof($tags); $i++) { ;?>
			<span><?php if($customdata->get('cf_tags_display')==2):?>
            	<a href="#"><?php echo $tags[$i];?></a>
            	<?php else :?>   
                <?php echo $tags[$i];?>
                <?php endif;?> 
            </span>
		<?php };?>
</div>
<?php endif;?>

<?php if($backtotop_display):?>
<div class="itemBack">
	<a href="#anchorItem<?php echo JRequest::getInt('id'); ?>">Back to top</a>
</div>
<?php endif;?>

</div>